/**
 * 
 */
package fr.utbm.gi.vi51.slizers.pw.environment;

import java.util.ArrayList;
import java.util.Collection;

import fr.utbm.gi.vi51.slizers.framework.agent.AgentBody;
import fr.utbm.gi.vi51.slizers.framework.environment.InfluenceCollector;
import fr.utbm.gi.vi51.slizers.pw.agent.action.CreatureActionInfluence;

/**
 * Implementation of an influence collector for the world.
 *
 * @author Tarik Belabbas
 *
 */
public class WorldInfluenceCollector extends InfluenceCollector< World >
{
	/**
	 * Parameterized constructor.
	 */
	public WorldInfluenceCollector( World _environment )
	{
		super( _environment );
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see fr.utbm.gi.vi51.slizers.framework.environment.InfluenceCollector#
	 * collectInfluences()
	 */
	@Override
	public Collection< CreatureActionInfluence > collectInfluences()
	{
		Collection< CreatureActionInfluence > influences =
			new ArrayList< CreatureActionInfluence >();
	
		CreatureActionInfluence influence;
		for ( AgentBody body : this.getEnvironment().getAgentBodies() )
		{
			influence = body.consumeInfluence();
			if ( influence != null )
			{
				influences.add( influence );
			}
		}
		
		return influences;
	}
}
